import request from '@/utils/request';
import type { AxiosPromise } from 'axios';

/**
 * 医院查询对象
 */
export interface HospitalQuery extends PageQuery {
  hospitalName?: string;
  city?: string;
  status?: string;
  settlementType?: string;
  beginTime?: string;
  endTime?: string;
}

/**
 * 医院对象
 */
export interface HospitalVO {
  hospitalId: number;
  hospitalName: string;
  hospitalCode: string;
  province: string;
  city: string;
  district: string;
  address: string;
  phone: string;
  contactPerson: string;
  businessHours: string;
  introduction: string;
  images: string;
  qualification: string;
  starLevel: string;
  latitude: number;
  longitude: number;
  status: string;
  settlementType: string;
  createTime: string;
}

/**
 * 医院表单对象
 */
export interface HospitalForm {
  hospitalId?: number;
  hospitalName: string;
  hospitalCode?: string;
  province: string;
  city: string;
  district: string;
  address: string;
  phone: string;
  contactPerson: string;
  businessHours?: string;
  introduction?: string;
  images?: string;
  qualification?: string;
  starLevel?: string;
  latitude?: number;
  longitude?: number;
  status?: string;
  settlementType?: string;
}

/**
 * 查询医院列表
 */
export function listHospital(query: HospitalQuery): AxiosPromise<HospitalVO[]> {
  return request({
    url: '/admin/beauty/hospital/list',
    method: 'get',
    params: query
  });
}

/**
 * 查询医院详细
 */
export function getHospital(hospitalId: number): AxiosPromise<HospitalVO> {
  return request({
    url: `/admin/beauty/hospital/${hospitalId}`,
    method: 'get'
  });
}

/**
 * 新增医院
 */
export function addHospital(data: HospitalForm) {
  return request({
    url: '/admin/beauty/hospital',
    method: 'post',
    data: data
  });
}

/**
 * 修改医院
 */
export function updateHospital(data: HospitalForm) {
  return request({
    url: '/admin/beauty/hospital',
    method: 'put',
    data: data
  });
}

/**
 * 删除医院
 */
export function delHospital(hospitalId: number | Array<number>) {
  return request({
    url: `/admin/beauty/hospital/${hospitalId}`,
    method: 'delete'
  });
}

/**
 * 启用医院
 */
export function enableHospital(hospitalId: number) {
  return request({
    url: `/admin/beauty/hospital/enable/${hospitalId}`,
    method: 'put'
  });
}

/**
 * 停用医院
 */
export function disableHospital(hospitalId: number) {
  return request({
    url: `/admin/beauty/hospital/disable/${hospitalId}`,
    method: 'put'
  });
}

/**
 * 获取医院关联的项目数量
 */
export function getHospitalProjectCount(hospitalId: number): AxiosPromise<number> {
  return request({
    url: `/admin/beauty/hospital/projectCount/${hospitalId}`,
    method: 'get'
  });
}
